import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

export default defineConfig({
    plugins: [react()],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    },
    optimizeDeps: {
        include: [
            'react',
            'react-dom',
            'react-router-dom',
            'antd',
            '@ant-design/icons',
            'dayjs',
            'echarts'
        ],
        force: true // 强制重新构建依赖
    },
    css: {
        modules: {
            localsConvention: 'camelCase',
            generateScopedName: '[local]_[hash:base64:5]'
        },
        preprocessorOptions: {
            scss: {
                additionalData: `
          @import "@/styles/variables.scss";
          @import "@/styles/mixins.scss";
        `
            }
        }
    },
    build: {
        sourcemap: true,
        rollupOptions: {
            output: {
                manualChunks: {
                    'react-vendor': ['react', 'react-dom'],
                    'antd-vendor': ['antd']
                }
            }
        }
    }
}) 